package com.yunfeng.supercall.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import android.content.Context;
import android.os.Parcel;
import android.text.TextUtils;

import com.ly.quickdev.library.utils.ShouZiMu;
import com.yunfeng.supercall.R;

/**
 * 朋友分组
 * 
 * @author 洋
 * 
 */
public class FriendsGroupBean extends SystemContactsBean {
	public static final int[] ICONS_GROUP2 = new int[] {

	R.drawable.ic_fans, R.drawable.ic_follows };

	public static final List<FriendsGroupBean> getSystemGroup(Context context) {
		List<FriendsGroupBean> friendsGroups = new ArrayList<FriendsGroupBean>();
		String[] str = context.getResources().getStringArray(
				R.array.systemFriendsGroupNames2);
		for (int i = 0; i < ICONS_GROUP2.length; i++) {
			FriendsGroupBean group = new FriendsGroupBean();
			group.setImgId(ICONS_GROUP2[i]);
			group.setGroupname(str[i]);
			group.setSticky("-");
			friendsGroups.add(group);
		}
		return friendsGroups;
	}

	@Override
	public int getContactsType() {
		// TODO Auto-generated method stub
		return TYPE_FRIENDS_GROUP;
	}

	public FriendsGroupBean() {
		super();
		// TODO Auto-generated constructor stub
	}

	public FriendsGroupBean(Parcel parcel) {
		super(parcel);
		groupname = parcel.readString();
		if(groupname != null) groupname = "";
		groupid = parcel.readInt();
		createtime = parcel.readString();
		if(createtime != null) createtime = "";
		number =parcel.readString();
		if(number != null) number = "";
	}
	private String number;
	
	private String num;
	
	public String getNum() {
		return num;
	}

	public void setNum(String num) {
		this.num = num;
	}

	public String getNumber() {
		return num;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	@Override
	public String getStickyItem() {
		// TODO Auto-generated method stub
		if (getImgId() != 0 || getUserid() == 0) {
			return getSticky();
		}
		if (TextUtils.isEmpty(groupname)) {
			return "#";
		}
		return String.valueOf(ShouZiMu.getSpells(groupname).charAt(0))
				.toUpperCase(Locale.US);
	}

	@Override
	public int compareTo(ContactsBaseBean another) {
		// TODO Auto-generated method stub
		FriendsGroupBean friendsGroup = (FriendsGroupBean) another;
		Character c1 = ShouZiMu.getSpells(groupname).charAt(0);
		Character c2 = ShouZiMu.getSpells(friendsGroup.groupname).charAt(0);
		return c1.compareTo(c2);
	}

	public static final Creator<FriendsGroupBean> CREATOR = new Creator<FriendsGroupBean>() {

		@Override
		public FriendsGroupBean[] newArray(int size) {
			// TODO Auto-generated method stub
			return new FriendsGroupBean[size];
		}

		@Override
		public FriendsGroupBean createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new FriendsGroupBean(source);
		}
	};

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		super.writeToParcel(dest, flags);
		dest.writeString(groupname);
		dest.writeInt(groupid);
		dest.writeString(createtime);
		dest.writeString(number);
	}

	private String groupname;
	private int groupid;
	private String createtime;

	public String getGroupname() {
		return groupname;
	}

	public void setGroupname(String groupname) {
		this.groupname = groupname;
	}

	public int getGroupid() {
		return groupid;
	}

	public void setGroupid(int groupid) {
		this.groupid = groupid;
	}

	public String getCreatetime() {
		return createtime;
	}

	public void setCreatetime(String createtime) {
		this.createtime = createtime;
	}

}
